/*******************************************************************************
 * @project: ServletTest
 * @package: com.burns.servlet.util
 * @file: GetDocumentByUrl.java
 * @author: Administrator
 * @created: 2017-5-16
 * @purpose:
 * 
 * @version: 1.0
 * 
 * Revision History at the end of file.
 * 
 * Copyright 2017 AcconSys All rights reserved.
 ******************************************************************************/

package com.burns.servlet.util;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

public class GetDocumentByUrl {

	public static String getStringByUrl(String url) throws Exception {
		// 链接URL
		URL url1 = new URL(url);
		// 返回结果集
		StringBuffer document = new StringBuffer();
		// 创建链接
		URLConnection conn = url1.openConnection();
		// 读取返回结果集
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				conn.getInputStream(), "utf-8"));
		String line = null;
		while ((line = reader.readLine()) != null) {
			document.append(line);
		}
		reader.close();
		return document.toString();
	}

}

/*******************************************************************************
 * <B>Revision History</B><BR>
 * [type 'revision' and press Alt + / to insert revision block]<BR>
 * 
 * 
 * 
 * Copyright 2017 AcconSys All rights reserved.
 ******************************************************************************/
